package com.qf.merchant.advice;

import com.qf.common.http.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;


@ControllerAdvice //controller增强, 提供统一的全局异常处理
public class ExceptionControllerAdvice {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result<?> handleBusinessException(HttpServletRequest request, Exception e) {
        String errmsg = e.getMessage();
        // e.printStackTrace();
        return Result.error(errmsg);
    }

}
